const App = getApp()

Page({
  data: {
    form: {
      homeCode: "",
      checkMobile: ""
    }
  },
  onLoad(options) {

  },
  onShow() {

  },
  changeHomeCode(item) {
    this.setData({
      'form.homeCode': item.detail.value
    })
  },
  changeCheckMobile(item) {
    this.setData({
      'form.checkMobile': item.detail.value
    })
  },
  async joinHome() {
    let data = await App.$axios.request({
      url: `/parent/user/mergeHomeCode`,
      data: {
        homeCode: this.data.form.homeCode,
        checkMobile: this.data.form.checkMobile
      },
      method: 'POST',
      loading: true,
    })
    if (data) {
      App.globalData.userInfo = {}
      wx.showToast({
        title: '操作成功',
      })
      wx.removeStorage({
        key: 'token',
      })
      wx.navigateBack({
        delta: 1
      })
    }
  }
})